from python_app.models.tracks import (
    StraightTrack,
    TrackData,
    Section,
    Route,
    RailwayNetwork,
)


# def test_straight_track():
track_station1_main = TrackData(
    "station1_main", [StraightTrack((100, 100), (300, 100))]
)
track_station1_side = TrackData(
    "station1_side",
    [
        StraightTrack((100, 150), (250, 150)),
        StraightTrack((250, 150), (300, 100)),
    ],
    semaphore_down_position=(300, 120),
)
track_station1_out = TrackData(
    "station1_out",
    [
        StraightTrack((300, 100), (400, 100)),
    ],
)
track_connection = TrackData(
    "connection",
    [
        StraightTrack((400, 100), (500, 100)),
        StraightTrack((500, 100), (600, 100)),
        StraightTrack((600, 100), (700, 100)),
    ],
)
track_station2_out = TrackData("station2_out", [StraightTrack((700, 100), (800, 100))])
track_station2_main = TrackData(
    "station2_main", [StraightTrack((800, 100), (1000, 100))]
)
track_station2_side = TrackData(
    "station2_side",
    [
        StraightTrack((800, 100), (850, 150)),
        StraightTrack((850, 150), (950, 150)),
    ],
    semaphore_up_position=(810, 120),
)

section_station1 = Section(
    "station1",
    [track_station1_main, track_station1_side, track_station1_out],
    [
        Route(
            "station1_main_departure",
            [("station1_main", "DOWN"), ("station1_out", "DOWN")],
            [
                ("station1_side", "DOWN")
            ],  # 正线出站进路放通时，侧线进路出站信号机必须进行防护
        ),
        Route(
            "station1_side_departure",
            [("station1_side", "DOWN"), ("station1_out", "DOWN")],
            [
                ("station1_main", "DOWN")
            ],  # 侧线出站进路放通时，正线进路出站信号机必须进行防护
        ),
        Route(
            "station1_side_arrival",
            [("station1_out", "UP"), ("station1_side", "UP")],
            [
                ("station1_main", "DOWN")
            ],  # 侧线进站进路放通时，正线进路出站信号机必须进行防护
        ),
        Route(
            "station1_main_arrival",
            [("station1_out", "UP"), ("station1_main", "UP")],
            [
                ("station1_side", "DOWN")
            ],  # 正线进站进路放通时，侧线进路出站信号机必须进行防护
        ),
    ],
)
section_station2 = Section(
    "station2",
    [track_station2_main, track_station2_side, track_station2_out],
    [
        Route(
            "station2_main_departure",
            [("station2_main", "UP"), ("station2_out", "UP")],
            [
                ("station2_side", "UP")
            ],  # 正线出站进路放通时，侧线进路出站信号机必须进行防护
        ),
        Route(
            "station2_side_departure",
            [("station2_side", "UP"), ("station2_out", "UP")],
            [
                ("station2_main", "UP")
            ],  # 侧线出站进路放通时，正线进路出站信号机必须进行防护
        ),
        Route(
            "station2_main_arrival",
            [("station2_out", "DOWN"), ("station2_main", "DOWN")],
            [
                ("station2_side", "UP")
            ],  # 正线进站进路放通时，侧线进路出站信号机必须进行防护
        ),
        Route(
            "station2_side_arrival",
            [("station2_out", "DOWN"), ("station2_side", "DOWN")],
            [
                ("station2_main", "UP")
            ],  # 侧线进站进路放通时，正线进路出站信号机必须进行防护
        ),
    ],
)
section_connection = Section(
    "section_connection",
    [track_connection],
    [
        Route("down", [("connection", "DOWN")], []),
        Route("up", [("connection", "UP")], []),
    ],
)
railway_network = RailwayNetwork(
    [section_station1, section_station2, section_connection],
    [
        (
            "station1",
            "station1_out",
            "DOWN",
            "section_connection",
            "connection",
            "UP",
        ),
        (
            "section_connection",
            "connection",
            "DOWN",
            "station2",
            "station2_out",
            "UP",
        ),
    ],
)
